-- fibonanci number

--  http://www.onlamp.com/pub/a/onlamp/2006/05/11/postgresql-plpgsql.html

CREATE OR REPLACE FUNCTION fib (
       fib_for integer
) RETURNS integer as $$
BEGIN
	IF fib_for < 2 THEN
	   RETURN fib_for;
	END IF;
	RETURN fib(fib_for - 2) + fib(fib_for - 1);
END;
$$ LANGUAGE plpgsql;
